{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The ancillary dimensions of the TT form = \n",
      "[2, 4, 8, 16, 32, 16, 8, 4, 2]\n"
     ]
    }
   ],
   "source": [
    "import numpy as np\n",
    "import BasicFun as bf\n",
    "import matplotlib.pyplot as plt\n",
    "\n",
    "# 考虑(2, 2, 2, 2, 2, 2, 2, 2, 2, 2)的8阶张量，进行无裁剪TT分解，查看分解后辅助指标的维数\n",
    "x = np.random.randn(2, 2, 2, 2, 2, 2, 2, 2, 2, 2)\n",
    "tensors = bf.ttd(x)[0]\n",
    "# 读取辅助指标维数\n",
    "a_dims = list()\n",
    "for x in tensors[:-1]:\n",
    "    a_dims.append(x.shape[-1])\n",
    "print('The ancillary dimensions of the TT form = ')\n",
    "print(a_dims)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "The error with different dimension cut-off = \n",
      "[0.9701071963645347, 0.9275457609342391, 0.880780132320654, 0.8174388155664142, 0.7410216924219561, 0.6497070334048256, 0.5547272438088919, 0.4491661638497071, 0.30221750257248536, 2.7069688820465293e-15]\n"
     ]
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYIAAAELCAYAAADURYGZAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4xLjMsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy+AADFEAAAgAElEQVR4nO3dd3hUZfr/8fedBAi9JUEg1NClCEQEFBE79r5id12RVXfXuqvfr7/d/brFdd11mygi9oaIrrL2slKkiIlIkyIJJaEmodck5P79MQMbsgEGyOQkmc/ruubKnDNnzvlkLsg95zzneR5zd0REJHbFBR1ARESCpUIgIhLjVAhERGKcCoG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w0N03mdmngLv72QFHkwCpEIiIxDg1FouIxDgVAhGRGKdCICIS41QIRERinAqBiEiMUyEQEYlxKgQiIjFOhUBEJMb9f/lNJk0OUcRtAAAAAElFTkSuQmCC\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "# 考虑(10, 10, 10, 10)的张量，计算不同截断维数下的误差\n",
    "y = np.random.randn(10, 10, 10)\n",
    "err = list()\n",
    "z0 = np.linalg.norm(y)\n",
    "for chi in range(1, 11):\n",
    "    tensors = bf.ttd(y, chi)[0]\n",
    "    y1 = bf.tt_product(tensors)\n",
    "    err.append(np.linalg.norm(y - y1) / z0)\n",
    "print('\\nThe error with different dimension cut-off = ')\n",
    "print(err)\n",
    "plt.plot(np.arange(1, 11), err, marker='x')\n",
    "plt.xlabel(r'dimension cut-off $\\chi$')\n",
    "plt.ylabel('relative error')\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.2"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
